package com.example.bms.storehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.bms.storehouse.entity.WaterEntity;
import com.example.bms.storehouse.service.WaterService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author Jiang
 * @email 337262603@qq.com
 * @date 2022-02-19 22:16:00
 */
@RestController
@RequestMapping("storehouse/water")
@CrossOrigin
public class WaterController {
    @Autowired
    private WaterService waterService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("storehouse:water:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = waterService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{wid}")
    //@RequiresPermissions("storehouse:water:info")
    public R info(@PathVariable("wid") Integer wid){
		WaterEntity water = waterService.getById(wid);

        return R.ok().put("water", water);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("storehouse:water:save")
    public R save(@RequestBody WaterEntity water){
		waterService.save(water);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("storehouse:water:update")
    public R update(@RequestBody WaterEntity water){
		waterService.updateById(water);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("storehouse:water:delete")
    public R delete(@RequestBody Integer[] wids){
		waterService.removeByIds(Arrays.asList(wids));

        return R.ok();
    }

}
